package com.cta.view.model;

import java.util.List;

import org.joda.money.BigMoneyProvider;
import org.joda.money.CurrencyUnit;
import org.joda.money.format.MoneyFormatter;
import org.joda.money.format.MoneyFormatterBuilder;
import org.joda.time.format.PeriodFormatter;
import org.joda.time.format.PeriodFormatterBuilder;

import com.cta.entity.AreaCodeRate;
import com.cta.view.model.discount.DiscountModel;

public class ConfigModel {

	private static MoneyFormatter formatter;
	public static PeriodFormatter durationFormatter;

	//private Long trunkId;
	private Long tariffId;
	private Long tariffGroupId;
	// validation config
	private boolean useValidation;
	private int shortNumber;
	private int longNumber;

	// save all discount rate type (date, day of week, hours)
	private List<DiscountModel> discountRates;

	private String discountType;
	private String currency;
	private int holidayDiscountValue;

	private String areaCode;
	private String areaName;
	private int firstBlock;
	private int secondBlock;

	private AreaCodeRate areaCodeRate;

	private String telco;

	static {
		MoneyFormatterBuilder bd = new MoneyFormatterBuilder();
		formatter = bd.appendAmount().appendCurrencyCode().toFormatter();

		durationFormatter = new PeriodFormatterBuilder().appendHours().appendSeparator(":").appendMinutes()
				.appendSeparator(":").appendSeconds().toFormatter();
	}
/*
	public Long getTrunkId() {
		return trunkId;
	}

	public void setTrunkId(Long trunkId) {
		this.trunkId = trunkId;
	}
*/
	public Long getTariffId() {
		return tariffId;
	}

	public void setTariffId(Long tariffId) {
		this.tariffId = tariffId;
	}

	public Long getTariffGroupId() {
		return tariffGroupId;
	}

	public void setTariffGroupId(Long tariffGroupId) {
		this.tariffGroupId = tariffGroupId;
	}

	public String getDiscountType() {
		return discountType;
	}

	public void setDiscountType(String discountType) {
		this.discountType = discountType;
	}

	public int getFirstBlock() {
		return firstBlock;
	}

	public void setFirstBlock(int firstBlock) {
		this.firstBlock = firstBlock;
	}

	public int getSecondBlock() {
		return secondBlock;
	}

	public void setSecondBlock(int secondBlock) {
		this.secondBlock = secondBlock;
	}

	public String getAreaCode() {
		return areaCode;
	}

	public void setAreaCode(String areaCode) {
		this.areaCode = areaCode;
	}

	public AreaCodeRate getAreaCodeRate() {
		return areaCodeRate;
	}

	public void setAreaCodeRate(AreaCodeRate areaCodeRate) {
		this.areaCodeRate = areaCodeRate;
	}

	public int getHolidayDiscountValue() {
		return holidayDiscountValue;
	}

	public void setHolidayDiscountValue(int holidayDiscountValue) {
		this.holidayDiscountValue = holidayDiscountValue;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public boolean isUseValidation() {
		return useValidation;
	}

	public void setUseValidation(boolean useValidation) {
		this.useValidation = useValidation;
	}

	public int getShortNumber() {
		return shortNumber;
	}

	public void setShortNumber(int shortNumber) {
		this.shortNumber = shortNumber;
	}

	public int getLongNumber() {
		return longNumber;
	}

	public void setLongNumber(int longNumber) {
		this.longNumber = longNumber;
	}

	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}

	public CurrencyUnit getCurrencyUnit() {
		return CurrencyUnit.of(this.currency);
	}

	public String formatMoney(BigMoneyProvider money) {
		return ConfigModel.formatter.print(money);
	}

	public void setDiscountRates(List<DiscountModel> discountRates) {
		this.discountRates = discountRates;
	}

	public List<DiscountModel> getDiscountRates() {
		return discountRates;
	}

	public String getTelco() {
		return telco;
	}

	public void setTelco(String telco) {
		this.telco = telco;
	}

}
